{
语法百题 解题报告：
 http://git.oschina.net/et0662/sznoi-grammar/ 
}
var
	i,n,k,a,b,c:integer;
begin
	readln(k);
	n:=0;
	for i:= 10000 to 30000 do
	begin
		a:=i div 100;
		b:=i div 10 mod 1000;
		c:=i mod 1000;
		if ((a mod k)=0) and ((b mod k)=0) and ((c mod k)=0) then
		begin
			writeln(i);
			inc(n);
		end;
	end;
	if(n=0)then
		writeln('No');
end.
